import java.io.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: fzykd
 * Date: 2022-04-10
 * Time: 13:30
 */
public class Demo3 {  // 写文件
    public static void main(String[] args) { //  按照字符来写
        try(Writer writer = new FileWriter("d:/test.txt")){
            writer.write("xyz");
        }catch (IOException e){
            e.printStackTrace();
        }
    }

    public static void main1(String[] args) {// 使用字节流写文件
        // 这种方式写入 都是清空原有文件的内容
        try(OutputStream outputStream = new FileOutputStream("d:/test.txt")){
             // 一次写入一个字节
//            outputStream.write(97);
//            outputStream.write(98);
//            outputStream.write(99);

            //一次写入多个字节
            byte[] buffer = new byte[]{97,98,99};
            outputStream.write(buffer);
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
